package com.balance.config.satoken;


import cn.dev33.satoken.model.wrapperInfo.SaDisableWrapperInfo;
import cn.dev33.satoken.stp.StpInterface;
import com.balance.pojo.sys.SysRole;
import com.balance.pojo.sys.SysUser;
import com.balance.service.sys.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Title: StpInterfaceImpl
 * @Author 小东
 * @Package com.balance.utils.satoken
 * @Date 2025/4/2 9:36
 * @description: satoken自定义权限加载接口实现类
 */
@Component
public class StpInterfaceImpl implements StpInterface {

    @Autowired
    private ISysUserService iSysUserService;

    @Override
    public List<String> getPermissionList(Object o, String s) {
        return null;
    }

    @Override
    public List<String> getRoleList(Object o, String s) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",o);
        SysUser sysUsers = iSysUserService.selectUserAndRoleList(map);
        List<String> list = new ArrayList<>();
        for (SysRole role : sysUsers.getRoles()) {
            list.add(role.getRoleCode());
        }
        System.out.println(list);
        return list;
    }

}